import requests
import json
import readExcel
import unittest
import readConfig
import test_backscanning
import test_status


class test_Order_Query(unittest.TestCase):
    def setUp(self):
        pass

    def test_order_query(self):
        url, data, headers = readExcel.read_Excel().read_excel(4)  # 根据excel用用例的函数，从0开始提交行数即可，case001就填写1
        sn = readConfig.readConfig('data', 'sn')
        token = test_status.test_Status().test_status()[0]
        order_no = test_backscanning.test_Backscanning().test_backscanning()[0]
        if 'sn' in data:
            if data['sn'] == '':
                data['sn'] = sn
        if 'token' in data:
            if data['token'] == '':
                data['token'] = token
        data['order_no'] = order_no
        # 开始提交参数到接口
        # print(data)
        r1 = requests.post(url, data=data, headers=headers)
        r2 = r1.json()
        print(json.dumps(r2, sort_keys=True, indent=4, separators=(',', ':'), ensure_ascii=False))
        self.assertEqual(r2['code'], 0)

    def tearDown(self):
        pass


if __name__ == '__main__':
    unittest.main()
